//package org.hgvc.webapp.ets.jsf.beans.admin;
//
//import java.util.ArrayList;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.List;
//
//import javax.faces.component.UIParameter;
//import javax.faces.component.html.HtmlOutputText;
//import javax.faces.event.ActionEvent;
//import javax.faces.model.SelectItem;
//
//import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
//import org.hgvc.webapp.ets.bo.Agreement;
//import org.hgvc.webapp.ets.bo.Member;
//import org.hgvc.webapp.ets.bo.MemberBooking;
//import org.hgvc.webapp.ets.bo.MemberComp;
//import org.hgvc.webapp.ets.bo.MemberInd;
//import org.hgvc.webapp.ets.bo.Package;
//import org.hgvc.webapp.ets.bo.Remark;
//import org.hgvc.webapp.ets.constant.AdminConstant;
//import org.hgvc.webapp.ets.constant.BookingConstant;
//import org.hgvc.webapp.ets.constant.CommonConstant;
//import org.hgvc.webapp.ets.spring.service.AdminPackageService;
//import org.hgvc.webapp.ets.spring.service.BookingService;
//import org.hgvc.webapp.ets.spring.service.MasterSetupService;
//import org.hgvc.webapp.ets.spring.service.MemberService;
//import org.hgvc.webapp.ets.spring.service.SystemService;
//import org.jocsb.base.AbstractBean;
//import org.jocsb.base.exception.BaseException;
//import org.richfaces.component.UICalendar;
//
//
//public class CopyOfAdminMemberBookingBean extends AbstractBean{
//	public static final String BEAN_NAME="adminMemberBookingBean";
//	
//	public static final String AB_ACTION_INVOKE="navConfirmMemberBookingAction";
//	public static final String NAV_VIEW_MEMBER_BOOKING="viewMemberBooking";
//	
//	private BookingService bookingService;
//	private MemberService memberService;
//	private AdminPackageService adminPackageService;
//	private MasterSetupService masterSetupService;
//	private SystemService systemService;
//	
//	private List<MemberBooking> memberBookingList;
//	private List<Member> memberList;
//	private List<Agreement> agreementList;
//	private List<Package> bookingPackageList;
//	private List<Remark> remarkList;
//	private MemberBooking memberBooking;
//	private Member member;
//	private Agreement agreement;
//	private Package bookingPackage;
//	private Remark remark;
//	
//	private List<SelectItem> selectRemark;
//	
//	private boolean catchError;
//	private boolean lookupMemberForm;
//	private boolean lookupAgreementForm;
//	private boolean lookupPackageForm;
//	
//	private List<SelectItem> selectSearchList;
//	private String searchField;
//	private String searchKeyword;
//	private boolean confirmBooking;
//	private boolean cancelBooking;
//	
//	private String bookingStatus;
//	private String actionNo;
//	
//	
//	
//	public void setSystemService(SystemService systemService) {
//		this.systemService = systemService;
//	}
//	public List<Agreement> getAgreementList() {
//		return agreementList;
//	}
//	public void setAgreementList(List<Agreement> agreementList) {
//		this.agreementList = agreementList;
//	}
//	public List<Package> getBookingPackageList() {
//		return bookingPackageList;
//	}
//	public void setBookingPackageList(List<Package> bookingPackageList) {
//		this.bookingPackageList = bookingPackageList;
//	}
//	public MemberBooking getMemberBooking() {
//		return memberBooking;
//	}
//	public void setMemberBooking(MemberBooking memberBooking) {
//		this.memberBooking = memberBooking;
//	}
//	public Member getMember() {
//		return member;
//	}
//	public void setMember(Member member) {
//		this.member = member;
//	}
//	public Agreement getAgreement() {
//		return agreement;
//	}
//	public void setAgreement(Agreement agreement) {
//		this.agreement = agreement;
//	}
//	public Package getBookingPackage() {
//		return bookingPackage;
//	}
//	public void setBookingPackage(Package bookingPackage) {
//		this.bookingPackage = bookingPackage;
//	}
//	public Remark getRemark() {
//		return remark;
//	}
//	public void setRemark(Remark remark) {
//		this.remark = remark;
//	}
//	public String getSearchField() {
//		return searchField;
//	}
//	public void setSearchField(String searchField) {
//		this.searchField = searchField;
//	}
//	public String getSearchKeyword() {
//		return searchKeyword;
//	}
//	public void setSearchKeyword(String searchKeyword) {
//		this.searchKeyword = searchKeyword;
//	}
//	public List<MemberBooking> getMemberBookingList() {
//		return memberBookingList;
//	}
//	public List<Member> getMemberList() {
//		return memberList;
//	}
//	public List<Remark> getRemarkList() {
//		return remarkList;
//	}
//	public List<SelectItem> getSelectRemark() {
//		return selectRemark;
//	}
//	public boolean isLookupMemberForm() {
//		return lookupMemberForm;
//	}
//	public boolean isLookupAgreementForm() {
//		return lookupAgreementForm;
//	}
//	public boolean isLookupPackageForm() {
//		return lookupPackageForm;
//	}
//	public List<SelectItem> getSelectSearchList() {
//		return selectSearchList;
//	}
//	public boolean isConfirmBooking() {
//		return confirmBooking;
//	}
//	public boolean isCancelBooking() {
//		return cancelBooking;
//	}
//	public void setBookingService(BookingService bookingService) {
//		this.bookingService = bookingService;
//	}
//	public void setMemberService(MemberService memberService) {
//		this.memberService = memberService;
//	}
//	public void setAdminPackageService(AdminPackageService adminPackageService) {
//		this.adminPackageService = adminPackageService;
//	}
//	public void setMasterSetupService(MasterSetupService masterSetupService) {
//		this.masterSetupService = masterSetupService;
//	}
//	
//	public String initMemberBookingListAction(){
//		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
//		try{
//			this.confirmBooking=false;
//			this.cancelBooking=false;
//			
//			this.memberBookingList=this.bookingService.getMemberBookingList(BookingConstant.STATUS_PENDING);
//			
//			this.searchField=BookingConstant.SEARCH_BOOKING_NO;
//			this.searchKeyword=null;
//			this.selectSearchList=new ArrayList<SelectItem>();
//			SelectItem bnSelectItem=new SelectItem(BookingConstant.SEARCH_BOOKING_NO,BookingConstant.SEARCH_BOOKING_NO);
//			this.selectSearchList.add(bnSelectItem);
//			SelectItem cnSelectItem=new SelectItem(BookingConstant.SEARCH_CONFIRMATION_NO,BookingConstant.SEARCH_CONFIRMATION_NO);
//			this.selectSearchList.add(cnSelectItem);
//		}catch(BaseException be){
//			initErrorBean(be);
//		}
//		return outcome;
//	}
//	
//	public String navAddMemberBookingAction(){
//		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
//		if (this.catchError)
//			outcome=null;
//		return outcome;
//	}
//	public void navAddMemberBookingActionEvent(ActionEvent event){
//		this.catchError=false;
//		try{
//			this.memberBooking=new MemberBooking();
//			this.member=new Member();
//			this.agreement=new Agreement();
//			this.remark=new Remark();
//			this.bookingPackage=new Package();
//			this.memberList=this.memberService.getMemberActiveList();
//			this.bookingPackageList=this.adminPackageService.getPackageList();
//			this.remarkList=this.masterSetupService.getRemarkList();
//			
//			this.selectRemark=new ArrayList<SelectItem>();
//			for(Remark remark : this.remarkList){
//				SelectItem selectItem=new SelectItem(remark.getRemarkId(),remark.getCode()+" - "+remark.getDesc());
//				this.selectRemark.add(selectItem);
//			}
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	public String addMemberBookingAction(){
//		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
//		if (this.catchError)
//			outcome=null;
//		return outcome;
//	}
//	public void addMemberBookingActionEvent(ActionEvent event){
//		this.catchError=false;
//		try{
//			this.bookingStatus=BookingConstant.STATUS_PENDING;
//			this.memberBooking.setCreatedBy(getThisUser());
//			this.memberBooking.setCreatedDate(new Date());
//			this.memberBooking.setIsDeleted(CommonConstant.NOT_DELETED);
//			if (this.memberBooking.getConfirmationNo()==null) this.memberBooking.setConfirmationNo("");
//			if (this.memberBooking.getConfirmationNo().length()>0 && this.memberBooking.getConfirmationDate()!=null){
//				this.memberBooking.setStatus(BookingConstant.STATUS_CONFIRM);
//				this.bookingStatus=BookingConstant.STATUS_CONFIRM;
//			}else
//				this.memberBooking.setStatus(BookingConstant.STATUS_PENDING);
//			
//			this.memberBooking.setMember(this.member);
//			this.memberBooking.setAgreement(this.agreement);
//			this.memberBooking.setBookingPackage(this.bookingPackage);
//			if (this.remark.getRemarkId().length()>0)
//				this.memberBooking.setRemark(this.remark);
//			else
//				this.memberBooking.setRemark(null);
//			this.bookingService.saveMemberBooking(this.memberBooking);
//			
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.bookingStatus);
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	
//	public String navEditMemberBookingAction(){
//		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
//		if (this.catchError)
//			outcome=null;
//		return outcome;
//	}
//	public void navEditMemberBookingActionEvent(ActionEvent event){
//		this.catchError=false;
//		UIParameter param=(UIParameter)event.getComponent().findComponent("memberBookingId");
//		String memberBookingId=param.getValue().toString();
//		try{
//			for (MemberBooking memberBookingP : this.memberBookingList){
//				if (memberBookingP.getMemberBookingId().equalsIgnoreCase(memberBookingId)){
//					this.memberBooking=memberBookingP;
//					break;
//				}
//			}
//			this.remarkList=this.masterSetupService.getRemarkList();
//			
//			this.selectRemark=new ArrayList<SelectItem>();
//			for(Remark remark : this.remarkList){
//				SelectItem selectItem=new SelectItem(remark.getRemarkId(),remark.getCode()+" - "+remark.getDesc());
//				this.selectRemark.add(selectItem);
//			}	
//			this.member=this.memberBooking.getMember();
//			this.agreement=this.memberBooking.getAgreement();
//			this.bookingPackage=this.memberBooking.getBookingPackage();
//			this.remark=this.memberBooking.getRemark();
//			if (this.remark==null) this.remark=new Remark();
//			
//			if (this.memberBooking.getStatus().equalsIgnoreCase(BookingConstant.STATUS_CONFIRM))
//				this.confirmBooking=true;
//			if (this.memberBooking.getStatus().equalsIgnoreCase(BookingConstant.STATUS_CANCEL))
//				this.cancelBooking=true;
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	public String updateMemberBookingAction(){
//		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
//		if (this.catchError)
//			outcome=null;
//		return outcome;
//	}
//	public void updateMemberBookingActionEvent(ActionEvent event){
//		this.catchError=false;
//		try{
//			this.bookingStatus=BookingConstant.STATUS_PENDING;
//			if (this.memberBooking.getStatus().equalsIgnoreCase(BookingConstant.STATUS_PENDING)){
//				if (this.memberBooking.getConfirmationNo().length()>0 && this.memberBooking.getConfirmationDate()!=null){
//					this.memberBooking.setStatus(BookingConstant.STATUS_CONFIRM);
//					this.bookingStatus = BookingConstant.STATUS_CONFIRM;
//				}
//			}
//			this.memberBooking.setMember(this.member);
//			this.memberBooking.setAgreement(this.agreement);
//			this.memberBooking.setBookingPackage(this.bookingPackage);
//			if (this.remark.getRemarkId().length()>0)
//				this.memberBooking.setRemark(this.remark);
//			else
//				this.memberBooking.setRemark(null);
//			this.memberBooking.setModifiedBy(getThisUser());
//			this.memberBooking.setModifiedDate(new Date());
//			this.bookingService.updateMemberBooking(this.memberBooking);
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.bookingStatus);
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	
//	public void cancelMemberBookingActionEvent(ActionEvent event){
//		this.catchError=false;
//		try{
//			this.memberBooking.setStatus(BookingConstant.STATUS_CANCEL);
//			this.memberBooking.setModifiedBy(getThisUser());
//			this.memberBooking.setModifiedDate(new Date());
//			this.bookingService.updateMemberBooking(this.memberBooking);
//			this.bookingStatus=BookingConstant.STATUS_CANCEL;
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.bookingStatus);
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	
//	public String searchMemberBookingAction(){
//		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
//		if (this.catchError)
//			outcome=null;
//		return outcome;
//	}
//	public void searchMemberBookingActionEvent(ActionEvent event){
//		this.catchError=false;
//		try{
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.searchField, this.searchKeyword,this.bookingStatus);
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	
//	public void lookupFormCloseActionEvent(ActionEvent event){
//		this.lookupMemberForm=false;
//		this.lookupAgreementForm=false;
//		this.lookupPackageForm=false;
//	}
//	
//	public void lookupMemberFormActionEvent(ActionEvent event){
//		this.catchError=false;
//		this.lookupMemberForm=true;
//		this.lookupAgreementForm=false;
//		this.lookupPackageForm=false;
//		try{
//			//this.memberList=this.memberService.getMemberActiveList();
//			
//			this.memberList=new ArrayList<Member>();
//			List<Member> memberPList=this.memberService.getMemberActiveList();	
//			for (Member member : memberPList){
//				if (member.getMemberType().equalsIgnoreCase(CommonConstant.MEMBER_TYPE_IND)){
//					MemberInd memberInd = this.memberService.getMemberIndByMemberId(member.getMemberId());
//				//	System.out.println("memberInd.getNameAsIcPassport()()="+memberInd.getNameAsIcPassport());
//					member.setName(memberInd.getNameAsIcPassport());
//				}else{
//					MemberComp memberComp = this.memberService.getMemberCompByMemberId(member.getMemberId());
//				//	System.out.println("memberComp.getCompName()="+memberComp.getCompName());
//					member.setName(memberComp.getCompName());
//				}
//				    
//				memberList.add(member);
//			}
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	public void lookupMemberSelectedActionEvent(ActionEvent event){
//		this.lookupMemberForm=false;
//		this.catchError=false;
//		UIParameter param=(UIParameter)event.getComponent().findComponent("memberId");
//		String memberId=param.getValue().toString();
//		for (Member memberP : this.memberList){
//			if (memberP.getMemberId().equalsIgnoreCase(memberId)){
//				this.member=memberP;
//				
//				this.memberBooking.setGuestName(this.member.getName());
//				break;
//			}
//		}
//	}
//	
//	public void lookupAgreementFormActionEvent(ActionEvent event){
//		this.catchError=false;
//		this.lookupMemberForm=false;
//		this.lookupAgreementForm=true;
//		this.lookupPackageForm=false;
//		try{
//			this.agreementList=this.bookingService.getValidMemberPointEntitleList(this.member.getMemberId());
//		}catch(Exception be){
//			this.catchError=true;
//			initErrorBean(new BaseException(be));
//		}
//	}
//	public void lookupAgreementSelectedActionEvent(ActionEvent event){
//		this.lookupAgreementForm=false;
//		UIParameter param=(UIParameter)event.getComponent().findComponent("agreementId");
//		String agreementId = param.getValue().toString();
//		for (Agreement agreementP : this.agreementList){
//			if (agreementP.getAgreementId().equalsIgnoreCase(agreementId)){
//				this.agreement=agreementP;
//				break;
//			}
//		}
//	}
//	
//	public void lookupPackageFormActionEvent(ActionEvent event){
//		this.catchError=false;
//		this.lookupMemberForm=false;
//		this.lookupAgreementForm=false;
//		this.lookupPackageForm=true;
//		try{
//			this.bookingPackageList=this.adminPackageService.getPackageList();
//		}catch(BaseException be){
//			this.catchError=true;
//			initErrorBean(be);
//		}
//	}
//	public void lookupPackageSelectedActionEvent(ActionEvent event){
//		this.lookupPackageForm=false;
//		UIParameter param=(UIParameter)event.getComponent().findComponent("packageId");
//		String packageId = param.getValue().toString();
//		for(Package packageP : this.bookingPackageList){
//			if (packageP.getPackageId().equalsIgnoreCase(packageId)){
//				this.bookingPackage=packageP;
//				break;
//			}
//		}
//	}
//	
//	public void pendingStatusSelectedActionEvent(ActionEvent event){
//		this.bookingStatus=BookingConstant.STATUS_PENDING;
//		System.out.println("this.bookingStatus="+this.bookingStatus);
//		try{
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.bookingStatus);
//		}catch(BaseException be){
//			initErrorBean(be);
//		}
//	}
//	public void confirmedStatusSelectedActionEvent(ActionEvent event){
//		this.bookingStatus=BookingConstant.STATUS_CONFIRM;
//		System.out.println("this.bookingStatus="+this.bookingStatus);
//		try{
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.bookingStatus);
//		}catch(BaseException be){
//			initErrorBean(be);
//		}
//	}
//	public void cancelledStatusSelectedActionEvent(ActionEvent event){
//		this.bookingStatus=BookingConstant.STATUS_CANCEL;
//		System.out.println("this.bookingStatus="+this.bookingStatus);
//		try{
//			this.memberBookingList=this.bookingService.getMemberBookingList(this.bookingStatus);
//		}catch(BaseException be){
//			initErrorBean(be);
//		}
//	}
//	public String getBookingStatus() {
//		return bookingStatus;
//	}
//	public void setBookingStatus(String bookingStatus) {
//		this.bookingStatus = bookingStatus;
//	}
//	
//	public void checkInCalendarActionEvent(ActionEvent event){
//		HtmlInputCalendar htmlInputCal=(HtmlInputCalendar) event.getComponent().findComponent("checkIn");
//		Date checkInDate =(Date) htmlInputCal.getValue();
//
//		int noOfNight = 1;
//		if (this.bookingPackage.getNoOfNights()!=null)
//			noOfNight=this.bookingPackage.getNoOfNights();
//		
//		Calendar cal=Calendar.getInstance();
//		cal.setTime(checkInDate);
//		cal.add(Calendar.DAY_OF_MONTH, noOfNight);
//		this.memberBooking.setCheckOutDate(cal.getTime());
//		
//		HtmlOutputText outtext = (HtmlOutputText)event.getComponent().findComponent("checkOut");
//		outtext.setValue(this.memberBooking.getCheckOutDate());
//	}
//	
//	public String navConfirmMemberBookingAction(String actionNoP,String... params){
//		this.actionNo = actionNoP;
//		String memberBookingId = params[1];
//		try{
//			
//			this.memberBooking = this.bookingService.getMemberBooking(memberBookingId);
//			this.member=this.memberBooking.getMember();
//			this.agreement=this.memberBooking.getAgreement();
//			this.bookingPackage=this.memberBooking.getBookingPackage();
//			this.remarkList=this.masterSetupService.getRemarkList();
//			if (this.remark==null) this.remark=new Remark();
//			this.selectRemark=new ArrayList<SelectItem>();
//			for(Remark remark : this.remarkList){
//				SelectItem selectItem=new SelectItem(remark.getRemarkId(),remark.getCode()+" - "+remark.getDesc());
//				this.selectRemark.add(selectItem);
//			}
//		}catch(BaseException be){
//			initErrorBean(be);
//		}
//		
//		return NAV_VIEW_MEMBER_BOOKING.concat("_"+getRoleName());
//	}
//	
//	public String partnerConfirmOrRejectMemberBookingAction(){
//		String outcome="partnerPortal";
//		try{
//			this.systemService.deleteActionBulletinByActionNo(this.actionNo);
//		}catch(BaseException be){
//			initErrorBean(be);
//		}
//		return outcome;
//	}
//	
//	public String backToPartnerPortal(){
//		String outcome="partnerPortal";
//		return outcome;
//	}
//	
//}
